package com.jbit.dm212.controller;

import com.jbit.dm212.common.ResponseResult;
import com.jbit.dm212.common.ResponseResultUtils;
import com.jbit.dm212.entity.dto.DmItemCommentDTO;
import com.jbit.dm212.entity.dto.DmItemDetailDTO;
import com.jbit.dm212.entity.dto.DmSchedulerDTO;
import com.jbit.dm212.entity.dto.DmSchedulerSeatPriceDTO;
import com.jbit.dm212.entity.vo.DmItemSearchVO;
import com.jbit.dm212.entity.vo.DmSchedulerSeatPriceVO;
import com.jbit.dm212.entity.vo.DmSchedulerVO;
import com.jbit.dm212.service.DmItemCommentService;
import com.jbit.dm212.service.DmItemService;
import com.jbit.dm212.service.DmSchedulerSeatPriceService;
import com.jbit.dm212.service.DmSchedulerService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/item/api/p")
public class DmItemDetailController {
    @Resource
    private DmItemService dmItemService;
    @Resource
    private DmSchedulerService dmSchedulerService;

    @Resource
    private DmItemCommentService itemCommentService;

    @Resource
    private DmSchedulerSeatPriceService schedulerSeatPriceService;
    @PostMapping("/queryItemDetail")
    public ResponseResult<DmItemDetailDTO> queryItemDetail(@RequestBody DmItemSearchVO itemSearchVO){
        return ResponseResultUtils.sendSuccess(dmItemService.getDetailById(itemSearchVO.getId()));
    }

    @PostMapping("/queryItemScheduler")
    public ResponseResult<List<DmSchedulerDTO>> queryItemScheduler(@RequestBody DmSchedulerVO schedulerVO){
        return ResponseResultUtils.sendSuccess(dmSchedulerService.getSchedulersByItemId(schedulerVO.getItemId()));
    }

    @PostMapping("/queryItemPrice")
    public ResponseResult<List<DmSchedulerSeatPriceDTO>> queryItemPrice(@RequestBody DmSchedulerSeatPriceVO schedulerSeatPriceVO){
        return ResponseResultUtils.sendSuccess(schedulerSeatPriceService.getPricesByScheduleId(schedulerSeatPriceVO.getScheduleId()));
    }

    @PostMapping("/queryItemComment")
    public ResponseResult<List<DmItemCommentDTO>> queryItemComment(@RequestBody DmItemSearchVO itemSearchVO){
        return ResponseResultUtils.sendSuccess(itemCommentService.getCommentsByItemId(itemSearchVO.getId()));
    }
}
